<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
String _user_id=(String)session.getAttribute("_user_id");
String _type=(String)session.getAttribute("_type");
session.setAttribute("_user_id", _user_id);
session.setAttribute("_type",_type);
if(_user_id==null || _user_id.length()==0 || _type==null || _type.length()==0){
	response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
	String newLocn = "logout.jsp";
	response.setHeader("Location",newLocn);
}
%>
<%@ page import="java.io.PrintWriter" %>
<%@ page import="com.baobaoyeye.conn.ConnMySQL" %>
<%@ page import="java.sql.ResultSet" %>
<%
ConnMySQL conn = new ConnMySQL();
String sql = "select * from subject;";
ResultSet rs = conn.executeQuery(sql);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Show Subjects</title>
</head>
<body>
<table border="1">

<tr>
<td>Subject ID</td>
<td>Subject Name</td>
<td>Teacher Name</td>
</tr>
<% while(rs.next()){ %>
<tr>
<td><%=rs.getString(1)%></td>
<td><%=rs.getString(2)%></td>
<%
String teacher_id=rs.getString(3);
ConnMySQL conn1 = new ConnMySQL();
String sql1 = "select teacher_name from teacher where teacher_id='"+teacher_id+"';";
ResultSet rs1 = conn1.executeQuery(sql1);
if(rs1.next()){
%>
<td><%=rs1.getString(1)%></td>
<%	
}
rs1.close();
%>

</tr>
<% }
rs.close();
%>
</table>
<a href="../addsubjects.jsp">Add Next</a>
<a href="../adminplace.jsp">Back Home</a>
<a href="http://localhost:8080/teach/logout.jsp">Logout</a>
</body>
</html>